
#include "BaseRtspServer.h"
#include <iostream>
#include <string>

using namespace std;

#define THIS_FILE	"BaseRtspServer"


//template<class CLIENT_CONNECTION>
//const int BaseRtspServer<CLIENT_CONNECTION>::RTSP_REQUEST_SIZE	= 4096;

//template<class CLIENT_CONNECTION>
//BaseRtspServer<CLIENT_CONNECTION>::~BaseRtspServer()
//{
//	cout << THIS_FILE << "destruct go!" << endl;
//}
//
//template<class CLIENT_CONNECTION>
//BaseRtspServer<CLIENT_CONNECTION>::BaseRtspServer(Proactor* proactor,unsigned short listenport):
//								   BaseAcceptor(proactor,listenport)
//{
//	cout << THIS_FILE << "construct ok!" << endl;
//}
//template<class CLIENT_CONNECTION>
//pj_bool_t BaseRtspServer<CLIENT_CONNECTION>::OnAccept(Proactor* proactor,pj_sock_t newsock,const pj_sockaddr_t *src_addr,int src_addr_len)
//{
//	char buf[100];
//	pj_sockaddr_print(src_addr,buf,sizeof(buf)-1,1);
//	printf("********OnAccept sock=%d addr=%s\n",newsock,buf);
//
////	CLIENT_CONNECTION *pRtspClientConnection = new CLIENT_CONNECTION(proactor,newsock);
////	p_proactor->RegisterHandle(pRtspClientConnection);
////	pStreamTcp->Recv(RTSP_REQUEST_SIZE);
//
//	return PJ_TRUE;
//};

RtspClientConnection::RtspClientConnection(Proactor* proactor,pj_sock_t newsock):
					  BaseStream(proactor,newsock)
{
}
pj_bool_t RtspClientConnection::OnDataRead(void *data,pj_size_t size,int status,pj_size_t* remainder)
{
	char* p = (char*)data;
	printf("RtspClientConnection::OnDataRead status=%d size=%d\n",status,size);
	if (TcpSocket::OnDataRead(data,size,status,remainder)!= PJ_TRUE)
		return PJ_FALSE;

	return handleMessage0(p,size,remainder);
};
pj_bool_t RtspClientConnection::OnDataSend(pj_ioqueue_op_key_t *send_key,int sendsize)
{
	printf("RtspClientConnection::OnDataSend sendsize=%d\n",sendsize);
	return PJ_TRUE;
};
RtspClientConnection::~RtspClientConnection()
{
	cout << THIS_FILE << " RtspClientConnection::~RtspClientConnection Go!" << endl;
}